<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
          .test1{
                height: 300px;
                width: 300px;
                background-color: red;
              position: absolute;
              left: 20px;
              z-index: 0;
              transition: 1s;
          }
         .test2{
             height: 300px;
             width: 300px;
             background-color: green;
             position: absolute;
             z-index: 1;
             transition: 1s;
          }
    </style>
</head>
<body>
<div class="test">
     <div class="test1">1</div>
     <div class="test2">1</div>
</div>
</body>
</html>